<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>阅读中</title>
		
		<script src="http://47.106.66.89:8080/js/vue.min.js"></script>
		<script src="http://47.106.66.89:8080/js/axios.min.js"></script>
		<link  href="http://47.106.66.89:8080/js/ele-2.15.7/theme-chalk/index.css" rel="stylesheet">
		<script src="http://47.106.66.89:8080/js/ele-2.15.7/index.js"></script>
		<link href="css/content.css" rel="stylesheet" type="text/css"/>
	</head>
	<body>
		
		
		<div id="app"    >
			<div class="muye-reader" id="reader">
				<div class="muye-reader-inner">
					<div class="muye-reader-nav top-nav-enter-done">
						<div class="muye-reader-nav-inner">
							<h1 class="muye-reader-nav-title"  @click="Jump">
								<svg class="muyeicon-icon muyeicon-icon-reader-icon-back " width="12" height="24" viewBox="0 0 12 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="margin: 2px 8px 2px 0px; vertical-align: top;">
									<path fill-rule="evenodd" clip-rule="evenodd" d="M10.2997 18.978C10.5861 19.2658 10.5824 19.7316 10.2914 20.0148V20.0148C10.0126 20.2863 9.56952 20.2904 9.28556 20.0243L1.27097 12.5125C0.907127 12.1403 0.907127 11.5368 1.27097 11.1646L9.28205 3.48947C9.56705 3.21642 10.0171 3.2182 10.2999 3.49349V3.49349C10.5881 3.77396 10.5963 4.23423 10.3185 4.52485L3.32031 11.8437C3.32031 11.8437 7.32726 15.9898 10.2997 18.978Z"></path>
								</svg>
								{{chapter.title}}
							</h1>
							<div class="use-reader-theme" v-if="!isLogged">
								<div class="slogin-user-avatar">
									<div class="slogin-user-avatar__buttons">
										<div class="slogin-user-avatar__buttons__item" @click="login()">
											登录
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					
					<div class="muye-reader-box"    >
						<div class="muye-reader-box-header">
							<h1 class="muye-reader-title">{{chapter.chapterTitle}}</h1>
							<div class="muye-reader-subtitle">
								<span class="desc-item"><span class="title">本章字数：</span>{{chapter.count}}字</span>
								<span class="desc-item"><span class="title">更新时间：</span>{{chapter.publishDate}}</span>
							</div>
						</div>
						
						<div class="muye-reader-box-content">
							<div>
								<p v-for="(paragraph, index) in paragraphs" :key="index">
									{{paragraph.trim()}}。
								</p>
								

								<p></p>
								
							</div>
							
						</div>
						
						 
						
						<div class="muye-reader-btns">
							<button class="btn-shang" @click="upper()" type="button">
								<span>上一章</span>
							</button>
							<button class="btn-xia" @click="below()" type="button">
								<span>下一章</span>
							</button>
						</div>
						
					</div>
					
					<div class="reader-toobar"> 

							<div class="reader-toolbar-item"  v-if="!donk" @click="addBookshelf">
								<svg class="muyeicon-icon muyeicon-icon-add-bookshelf reader-toolbar-item-icon" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
									
									<path fill-rule="evenodd" clip-rule="evenodd" d="M22.2659 16.604C22.5416 16.6279 22.7524 16.9501 22.75 17.2249C22.7476 17.4942 22.5502 17.791 22.2827 17.821C22.2716 17.8223 22.2608 17.8231 22.2496 17.8241C22.1002 17.8382 20.9498 17.9429 19.7693 17.9429C18.606 17.9429 17.447 17.8249 17.2672 17.8058C17.2506 17.804 17.2347 17.8028 17.2182 17.8007C16.9526 17.767 16.75 17.4932 16.75 17.2249C16.75 16.9519 16.9602 16.6587 17.234 16.6351L18.6765 16.4879C19.3742 16.4277 20.0758 16.4279 20.7735 16.4884L22.2659 16.604Z"></path>
									
									<path fill-rule="evenodd" clip-rule="evenodd" d="M19.1563 14.6823C19.1802 14.4067 19.5023 14.1959 19.7772 14.1983 20.0464 14.2006 20.3432 14.398 20.3733 
									14.6655 20.3745 14.6767 20.3753 14.6875 20.3764 14.6987 20.3905 14.8481 20.4951 15.9985 20.4951 17.179 20.4951 18.3422 20.3771 19.5012 20.358 19.6811 20.3562 19.6977 20.3551 19.7135 20.353 19.7301 20.3192 19.9956 20.0454 20.1982 19.7772 20.1982 19.5041 20.1982 19.2109 19.9881 19.1873 19.7142L19.0401 18.2717C18.9799 17.574 18.9801 16.8724 19.0406 16.1748L19.1563 14.6823zM3.5 6.74515C3.49998 5.5025 4.50735 4.49512 5.75 4.49512H9.1516C11.2227 4.49512 12.9016 6.17402 12.9016 8.24507L12.9017 19.6994C12.9017 20.0185 12.6998 20.3027 12.3984 20.4076 12.097 20.5126 11.7622 20.4153 11.564 20.1652 10.801 19.2025 9.62125 18.5862 8.296 18.5862H5.75013C4.5075 18.5862 3.50015 17.5788 3.50013 16.3362L3.5 6.74515zM5.75 5.99512C5.33578 5.99512 4.99999 6.33091 5 6.74513L5.00013 16.3362C5.00014 16.7504 5.33592 17.0862 5.75013 17.0862H8.296C9.4427 17.0862 10.5101 17.4266 11.4017 18.011L11.4016 8.24509C11.4016 7.00246 10.3942 5.99512 9.1516 5.99512H5.75z"></path>
									 
									<path fill-rule="evenodd" clip-rule="evenodd" d="M18.2461 4.49512C19.4887 4.49512 20.4961 5.50248 20.4961 6.74512L20.3205 12.3478C20.3116 12.631 20.0795 12.856 19.7962 12.856C19.5165 12.856 19.286 12.6365 19.2722 12.3572L18.9961 6.74512C18.9961 6.3309 18.6603 5.99512 18.2461 5.99512H15.1514C13.9087 5.99512 12.9014 7.00248 12.9014 8.24512V17.9929C13.659 17.4962 14.4786 17.2632 15.4114 17.2043C15.6902 17.1868 15.917 17.4155 15.917 17.6949C15.917 17.9742 15.6886 18.1963 15.414 18.2481C14.3149 18.4552 13.4033 19.3091 12.7391 20.147C12.5409 20.3971 12.2061 20.4944 11.9047 20.3895C11.6033 20.2845 11.4014 20.0003 11.4014 19.6812V8.24512C11.4014 6.17405 13.0803 4.49512 15.1514 4.49512H18.2461Z"></path>
								</svg>
								<div > 加书架</div>

							</div>
							<div class="reader-toolbar-item"  v-if="donk"  >
								<svg class="muyeicon-icon muyeicon-icon-add-bookshelf reader-toolbar-item-icon" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">

									<path fill-rule="evenodd" clip-rule="evenodd" d="M22.2659 16.604C22.5416 16.6279 22.7524 16.9501 22.75 17.2249C22.7476 17.4942 22.5502 17.791 22.2827 17.821C22.2716 17.8223 22.2608 17.8231 22.2496 17.8241C22.1002 17.8382 20.9498 17.9429 19.7693 17.9429C18.606 17.9429 17.447 17.8249 17.2672 17.8058C17.2506 17.804 17.2347 17.8028 17.2182 17.8007C16.9526 17.767 16.75 17.4932 16.75 17.2249C16.75 16.9519 16.9602 16.6587 17.234 16.6351L18.6765 16.4879C19.3742 16.4277 20.0758 16.4279 20.7735 16.4884L22.2659 16.604Z"></path>

									<path fill-rule="evenodd" clip-rule="evenodd" d="M19.1563 14.6823C19.1802 14.4067 19.5023 14.1959 19.7772 14.1983 20.0464 14.2006 20.3432 14.398 20.3733
										14.6655 20.3745 14.6767 20.3753 14.6875 20.3764 14.6987 20.3905 14.8481 20.4951 15.9985 20.4951 17.179 20.4951 18.3422 20.3771 19.5012 20.358 19.6811 20.3562 19.6977 20.3551 19.7135 20.353 19.7301 20.3192 19.9956 20.0454 20.1982 19.7772 20.1982 19.5041 20.1982 19.2109 19.9881 19.1873 19.7142L19.0401 18.2717C18.9799 17.574 18.9801 16.8724 19.0406 16.1748L19.1563 14.6823zM3.5 6.74515C3.49998 5.5025 4.50735 4.49512 5.75 4.49512H9.1516C11.2227 4.49512 12.9016 6.17402 12.9016 8.24507L12.9017 19.6994C12.9017 20.0185 12.6998 20.3027 12.3984 20.4076 12.097 20.5126 11.7622 20.4153 11.564 20.1652 10.801 19.2025 9.62125 18.5862 8.296 18.5862H5.75013C4.5075 18.5862 3.50015 17.5788 3.50013 16.3362L3.5 6.74515zM5.75 5.99512C5.33578 5.99512 4.99999 6.33091 5 6.74513L5.00013 16.3362C5.00014 16.7504 5.33592 17.0862 5.75013 17.0862H8.296C9.4427 17.0862 10.5101 17.4266 11.4017 18.011L11.4016 8.24509C11.4016 7.00246 10.3942 5.99512 9.1516 5.99512H5.75z"></path>

									<path fill-rule="evenodd" clip-rule="evenodd" d="M18.2461 4.49512C19.4887 4.49512 20.4961 5.50248 20.4961 6.74512L20.3205 12.3478C20.3116 12.631 20.0795 12.856 19.7962 12.856C19.5165 12.856 19.286 12.6365 19.2722 12.3572L18.9961 6.74512C18.9961 6.3309 18.6603 5.99512 18.2461 5.99512H15.1514C13.9087 5.99512 12.9014 7.00248 12.9014 8.24512V17.9929C13.659 17.4962 14.4786 17.2632 15.4114 17.2043C15.6902 17.1868 15.917 17.4155 15.917 17.6949C15.917 17.9742 15.6886 18.1963 15.414 18.2481C14.3149 18.4552 13.4033 19.3091 12.7391 20.147C12.5409 20.3971 12.2061 20.4944 11.9047 20.3895C11.6033 20.2845 11.4014 20.0003 11.4014 19.6812V8.24512C11.4014 6.17405 13.0803 4.49512 15.1514 4.49512H18.2461Z"></path>
								</svg>
								<div > 已在书架</div>

							</div>
							<div class="reader-toolbar-item" @click="drawer = true">
								<svg class="muyeicon-icon muyeicon-icon-chapter-menu reader-toolbar-item-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
									<path d="M4.5 5.75C4.5 4.50736 5.50736 3.5 6.75 3.5H17.25C18.4926 3.5 19.5 4.50736 19.5 5.75V18.25C19.5 19.4926 18.4926 20.5 17.25 20.5H6.75C5.50736 20.5 4.5 19.4926 4.5 18.25V5.75Z" stroke="#252525" stroke-width="1.5"></path>
									<path fill-rule="evenodd" clip-rule="evenodd" d="M8.31738 8.75831C8.31738 8.17312 8.7595 7.91016 9.15259 7.91016L14.9997 8.16598C15.9177 8.16598 15.9177 9.5 14.9997 9.5L9.15259 9.60916C8.7595 9.60916 8.31738 9.34351 8.31738 8.75831zM8.31738 12.6436C8.31738 12.0584 8.7595 11.7954 9.15259 11.7954L13.4997 12C14.4177 12 14.4177 13.3212 13.4997 13.3212L9.15259 13.4944C8.7595 13.4944 8.31738 13.2288 8.31738 12.6436z" fill="#252525"></path>
								</svg>
								<div>目录</div>
							</div>

							<div class="reader-toolbar-item" @click="centerDialogVisible = true">
								<svg class="muyeicon-icon muyeicon-icon-reader-dark reader-toolbar-item-icon" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
									<path fill-rule="evenodd" clip-rule="evenodd" d="M17.8594 7.73041C17.7972 7.69239 17.7427 7.64339 17.6963 7.58716C16.7647 6.4575 15.2771 5.68597 13.8177
										5.26246C14.1694 6.39374 14.2536 7.59817 14.0468 8.80275C13.7934 10.2806 13.1057 11.6041 12.1336 12.6481C11.1969 13.72419.95246 14.5465 8.50907 14.953C7.33274 15.2846 6.12614 15.3268 4.96433
										15.0953C6.29448 18.3564 9.83676 20.2784 13.4209 19.4638C17.0706 18.633719.473 14.3522 19.0113 10.6489C19.0043 10.5926 19.0046 10.5357 19.0132 10.4795C19.1125 9.83164 20.0361 9.80445 20.1734 10.4454L20.320911.1344C20.9476 15.7137 18.304 20.0577 13.7895 21.0845C8.9885922.1757 4.23275 19.2523 3.03569 14.5386L3.02941 14.5138L3.0246614.4887C3.00155 14.3668 2.99216 14.238 2.9988 14.115C3.00213
										14.0535 3.01028 13.9781 3.0295 13.8974C3.0457 13.8293 3.08423
										 13.6932 3.18337 13.5559C3.41601 13.2337 3.76588 13.1975 3.83752
										 13.1901C3.84002 13.1898 3.84398 13.1894 3.84398 13.1894C4.12938 13.1579 4.42979 13.2281 4.6911 13.3172L4.70929 13.3195L4.77352 13.3384C5.83528 13.6501 6.96025 13.6628 8.0583 13.3532C9.08414 13.0643 9.98559 12.5027 10.6941 11.7606L10.6851 11.7513C10.7579 11.6813 10.829 11.6094 10.8982 11.5358C10.9641 11.4594 11.0281 11.3812 11.0901 11.3016L11.1003 11.3095C11.7642 10.5273 12.2285 9.57227 12.4086 8.52184C12.6017 7.39745 12.4715 6.2798 12.0505 5.25644L12.0251 5.19454L12.0209 5.17668C11.9049 4.92613 11.8037 4.6347 11.8052 4.34757C11.8052 4.34757 11.8052 4.34358 11.8052 4.34107C11.8051 4.26905 11.8045 3.91732 12.1006 3.65227C12.2268 3.53932 12.3581 3.48678 12.4241 3.46355C12.5024 3.43599 12.5765 3.42001 12.6374 3.41026C12.759 3.39081 12.8881 3.38668 13.0118 3.39691L13.0372 3.39902L13.0625 3.40268C15.3442 3.73348 17.2809 5.0675 18.6522 6.73669C18.7451 6.84975 18.7937 6.99224 18.7937 7.13856L18.7937 7.20659C18.7937 7.68616 18.2686 7.9806 17.8594 7.73041Z"></path>
								</svg>
								<div>打赏</div>
							</div>
						<div class="reader-toolbar-item" @click="comment()">
							<svg class="muyeicon-icon muyeicon-icon-reader-dark reader-toolbar-item-icon" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
								<path fill-rule="evenodd" clip-rule="evenodd" d="M17.8594 7.73041C17.7972 7.69239 17.7427 7.64339 17.6963 7.58716C16.7647 6.4575 15.2771 5.68597 13.8177
										5.26246C14.1694 6.39374 14.2536 7.59817 14.0468 8.80275C13.7934 10.2806 13.1057 11.6041 12.1336 12.6481C11.1969 13.72419.95246 14.5465 8.50907 14.953C7.33274 15.2846 6.12614 15.3268 4.96433
										15.0953C6.29448 18.3564 9.83676 20.2784 13.4209 19.4638C17.0706 18.633719.473 14.3522 19.0113 10.6489C19.0043 10.5926 19.0046 10.5357 19.0132 10.4795C19.1125 9.83164 20.0361 9.80445 20.1734 10.4454L20.320911.1344C20.9476 15.7137 18.304 20.0577 13.7895 21.0845C8.9885922.1757 4.23275 19.2523 3.03569 14.5386L3.02941 14.5138L3.0246614.4887C3.00155 14.3668 2.99216 14.238 2.9988 14.115C3.00213
										14.0535 3.01028 13.9781 3.0295 13.8974C3.0457 13.8293 3.08423
										 13.6932 3.18337 13.5559C3.41601 13.2337 3.76588 13.1975 3.83752
										 13.1901C3.84002 13.1898 3.84398 13.1894 3.84398 13.1894C4.12938 13.1579 4.42979 13.2281 4.6911 13.3172L4.70929 13.3195L4.77352 13.3384C5.83528 13.6501 6.96025 13.6628 8.0583 13.3532C9.08414 13.0643 9.98559 12.5027 10.6941 11.7606L10.6851 11.7513C10.7579 11.6813 10.829 11.6094 10.8982 11.5358C10.9641 11.4594 11.0281 11.3812 11.0901 11.3016L11.1003 11.3095C11.7642 10.5273 12.2285 9.57227 12.4086 8.52184C12.6017 7.39745 12.4715 6.2798 12.0505 5.25644L12.0251 5.19454L12.0209 5.17668C11.9049 4.92613 11.8037 4.6347 11.8052 4.34757C11.8052 4.34757 11.8052 4.34358 11.8052 4.34107C11.8051 4.26905 11.8045 3.91732 12.1006 3.65227C12.2268 3.53932 12.3581 3.48678 12.4241 3.46355C12.5024 3.43599 12.5765 3.42001 12.6374 3.41026C12.759 3.39081 12.8881 3.38668 13.0118 3.39691L13.0372 3.39902L13.0625 3.40268C15.3442 3.73348 17.2809 5.0675 18.6522 6.73669C18.7451 6.84975 18.7937 6.99224 18.7937 7.13856L18.7937 7.20659C18.7937 7.68616 18.2686 7.9806 17.8594 7.73041Z"></path>
							</svg>
							<div>评论</div>
						</div>
					</div>

					<el-drawer
							:title="chapter.title"
							:visible.sync="drawer"
							direction="rtl"
							:before-close="handleClose">
						<el-table
								:data="tableData"
								stripe
								style="width: 100%"
								@row-click="handleRowClick"
								:row-key="row => row.chapterTitle">
							<el-table-column
									prop="chapterTitle"
									label="章节标题"
									width="300">
							</el-table-column>
							<el-table-column
									prop="publishDate"
									label="发布时间"
									width="150">
							</el-table-column>

						</el-table>
					</el-drawer>


					<el-dialog
							title="提示"
							:visible.sync="centerDialogVisible"
							width="50%"
							center>
						<div style="background-color: #DCF0F7;width: 85%;line-height: 100px; margin-left: 4%;">
							<div style="margin: 0 30px 0 30px;">
								<img :src="this.user.avatar" style="width: 80px;height: 80px;border-radius: 50%;overflow: hidden;"/>
								<span> 用户手机号：{{this.user.phone}}</span>
								<span name="balance" style="float: right;"> 账户余额：￥{{this.user.money}}</span>
							</div>
						</div>
						<span style=" width: 85%;line-height: 50px; margin-left: 4%;font-size: 16px;">请选择打赏金额:</span>
						<div style=" width: 85%;line-height: 50px; margin-left: 4%;">
							<el-radio v-model="radio1" label="10" border>10元</el-radio>
							<el-radio v-model="radio1" label="50" border>50元</el-radio>
							<el-radio v-model="radio1" label="100" border>100元</el-radio>

						</div>
						<span slot="footer" class="dialog-footer">
    						<el-button @click="centerDialogVisible = false">取 消</el-button>
    						<el-button type="primary" @click="swch()">确 定</el-button>
  						</span>
					</el-dialog>
				</div>
			</div>
				
		</div>


	</body>
	
	<script>




		var v = new Vue({
			el : "#app",
			data() {
				return {
					chapter: {
						chapterId: '',
						novelId: '',
						title: '',
						chapterTitle: '',
						content: '',
						publishDate: '',
						count: 0,
						progress: 0,

					},

					scrollTop: 0, // 滚动条距离顶部的距离

					scrollHeight: 0, // 页面高度
					isLogged: false,
					paragraphs: [], // 章节内容
					bookshelf:{
						bookshelfId: '',
						userId: '',
						novelId: '',
						chapterId: '',

					},
					drawer: false,//侧边栏
					donk: false, // 是否在书架
					tableData: [{
						chapterId: '1',
						chapterTitle: '第一章 序章',
						publishDate: '2021-01-01',

					} ],
					centerDialogVisible: false,//居中对话框
					user: {
						userId: '',
						avatar: '',
						username: '',
						password: '',
						introduction: '',
						phone: '',
						email: '',
						money: 0,
					},
					radio1: '',//选择的打赏金额



				};
			},
			mounted() {



				// 获取 URL 中的参数值（以 # 号分隔）
				let hashValue = window.location.hash;
				// 去掉 # 号，只保留值部分
				this.chapter.chapterId  = hashValue.substring(1);

			 	this.iflogin();






			},
			beforeDestroy() {
				// 移除滚动事件监听器
				window.removeEventListener('scroll', this.handleScroll,true);
			},

			methods: {


				// 登录
				login(){
					window.location.href = 'login.html';
				},
				//判断是否登录
				iflogin(){
					axios.get('/user/iflogin').then(res=>{

						if(res.data != ""){
							this.bookshelf.userId = res.data;

							this.isLogged =  true;

							// 监听滚动事件
							window.addEventListener('scroll', this.handleScroll,true);


						}
						this.selectChapter();
						this.queryBalance();

					});

				},
				// 获取章节内容
				selectChapter(){

					axios.post('/other/selectChap',this.chapter).then(res => {
						this.chapter = res.data;
						this.bookshelf.novelId = this.chapter.novelId;
						// this.bookshelf.chapterId = this.chapter.chapterId;
						this.selectTitle(this.chapter.novelId);
						this.paragraphs = this.chapter.content.split("。");

						this.isInBookshelf();//判断是否这本小说在书架中
						this.showCatalog(); //显示目录
						this.addHeat(this.chapter.novelId);

					});

				},
				// 获取小说标题
				selectTitle(novelId){
					axios.get('/other/novel/selectnovelId?novelId='+novelId).then(res => {
						this.chapter.title = res.data;

					});
				},
				// 跳转到小说详情页
				Jump(){

					window.location.href = 'novel.html#'+this.chapter.novelId;
				},



				//  滚动处理函数
				handleScroll(event) {
					// 获取滚动条距离顶部的距离
					this.chapter.progress = event.target.scrollTop;


					if(this.chapter.progress > 100){
						this.sendScrollDataToBackend();
					}



				},
				// 发送滚动数据到后端的函数
				sendScrollDataToBackend() {

					axios.post('/other/setprogress',this.chapter).then(res => {
						 console.log(res.data);
					});
				},

				//回到之前的阅读位置
				backToPosition( ) {

					if(this.chapter.chapterId  == this.bookshelf.chapterId){
						// 获取滚动条距离顶部的距离
						axios.post('/other/getprogress',this.chapter).then(res => {
							this.chapter.progress = res.data;
							this.scrollToOffset(this.chapter.progress);
							console.log(res.data);

						});
					}



				},
				// 滚动到指定偏移量
				scrollToOffset(offset) {
					// 获取当前页面的滚动位置
					const currentScrollPosition = window.pageYOffset || document.documentElement.scrollTop;

					// 计算新的滚动位置
					const newScrollPosition = currentScrollPosition + offset;
					console.log(newScrollPosition);
					// 获取包含滚动条的元素
					var reader = document.getElementById('reader');

					// 设置滚动条距离顶部的位置（假设设置为100px）
					reader.scrollTop = newScrollPosition;

				},

				// 添加到书架
				addBookshelf(){
					if(this.bookshelf.userId != ""){
						this.bookshelf.chapterId = this.chapter.chapterId;
						axios.post('/other/addBookshelf',this.bookshelf).then(res => {
							if(res.data == 1){
								alert("已添加到书架！");
								this.donk = true;
							}
							else{
								alert("添加失败！");
							}

						});
					}
					else{
						window.location.href = 'login.html';
					}

				},

				// 是否关闭侧边栏
				handleClose(done) {
					this.$confirm('确认关闭？')
						.then(_ => {
							done();
						})
						.catch(_ => {});
				},

				//判断是否这本小说在书架中
				isInBookshelf(){
					if(this.bookshelf.userId != ""){

						axios.post('/other/isInBookshelf',this.bookshelf).then(res=>{

							if(res.data == "" || res.data == null){
								this.donk = false;
							}
							else{
								this.donk = true;
								this.bookshelf = res.data;

							}
							this.backToPosition(); //回到之前的阅读位置



						});

					}
				},
				//显示目录
				showCatalog() {
					axios.get('/other/selectChapter?novelId=' + this.chapter.novelId).then(res => {
						this.tableData = res.data;

					});


				},
				// 点击目录跳转到指定章节
				handleRowClick(row,event,column) {
					// 在这里处理行点击事件，row参数是被点击的行对应的数据对象
					// 获取包含滚动条的元素
					var reader = document.getElementById('reader');

					// 设置滚动条距离顶部的位置（假设设置为100px）
					reader.scrollTop = 0;
					this.bookshelf.chapterId = row.chapterId;
					if(this.bookshelf.bookshelfId != ""){
						axios.post('/other/updatabookshelf',this.bookshelf).then(res => {
							if(res.data == 1){
								//删除偏移量
								axios.post('/other/deleteprogress',this.chapter).then(res => {
									console.log(res.data);
									window.location.href = 'content.html#' + row.chapterId;

									// 刷新页面
									location.reload();

								});
							}

						});
					}
					else{
						window.location.href = 'content.html#' + row.chapterId;

						// 刷新页面
						location.reload();
					}



				},
				//上一章
				upper(){
					const index = this.tableData.findIndex(item => item.chapterId === this.chapter.chapterId);
					if(index == 0){
						alert("已经是第一章了！");
					}
					else{
						this.handleRowClick(this.tableData[index-1],null,null);
					}

				},
				//下一章
				below(){
					const index = this.tableData.findIndex(item => item.chapterId === this.chapter.chapterId);
					if(index == this.tableData.length-1){
						alert("已经是最后一章了！");
					}
					else{
						this.handleRowClick(this.tableData[index+1],null,null);
					}
				},
				//查询用户账号余额
				queryBalance(){
					if(this.bookshelf.userId != ""){
						axios.get('/user/getUser?userId='+this.bookshelf.userId).then(res => {
							this.user = res.data;

						});
					}
					else{
						window.location.href = 'login.html';
					}


				},
				// 打赏作者
				swch(){
					let money =this.user.money - this.radio1;
					if(money >=0){
						this.user.money = money;
						axios.post('/user/updateUser',this.user).then(res => {
							if(res.data == 1){
								axios.get('/other/novel/updataMoney?money='+this.radio1+'&novelId='+this.bookshelf.novelId).then(res => {
									if(res.data == 1){
										alert("打赏成功！");
									}
									else{
										alert("打赏失败！");
									}
								});

							}
							else{
								alert("打赏失败！");
							}

						});

						this.centerDialogVisible = false;
					}
					else{
						alert("余额不足！请前往个人中心充值！")
					}



				},

				//小说热度增加
				addHeat(novelId){
					axios.get('/ranking/diji?novelId='+novelId).then(res => {
						if(res.data != null){
							console.log("热度增加成功！");
						}
					});
				},
				//跳转评论页面
				comment(){
					window.location.href = 'comment.html#'+this.chapter.novelId;
				}



			}


		});
	</script>
</html>
